//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//


package org.flowable.ui.common.security;


import java.util.Collections;
import java.util.Iterator;
import org.flowable.idm.api.User;
import org.flowable.spring.security.UserDto;
import org.flowable.ui.common.model.RemoteUser;
import org.flowable.ui.common.model.UserRepresentation;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;


public class SecurityUtils {
    private static User assumeUser;


    private SecurityUtils() {
    }


    public static String getCurrentUserId() {
        User user = getCurrentUserObject();
        return user != null ? user.getId() : null;
    }


    public static User getCurrentUserObject() {
        RemoteUser remoteUser = new RemoteUser();
        remoteUser.setId( "1");
        remoteUser.setFirstName("admin");
        remoteUser.setDisplayName("admin");
        remoteUser.setPassword("Abc123++");
        return remoteUser;
    }


    public static FlowableAppUser getCurrentFlowableAppUser() {
        RemoteUser remoteUser = new RemoteUser();
        remoteUser.setId( "1");
        remoteUser.setFirstName("admin");
        remoteUser.setDisplayName("admin");
        remoteUser.setPassword("Abc123++");
        return new FlowableAppUser(remoteUser, "1", Collections.emptyList());
    }


    public static boolean currentUserHasCapability(String capability) {
        return true;
    }


    public static void assumeUser(User user) {
        assumeUser = user;
    }


    public static void clearAssumeUser() {
        assumeUser = null;
    }


    public static UserRepresentation getAdminUser() {
        UserRepresentation userRepresentation = new UserRepresentation();
        userRepresentation.setFirstName("admin");
        userRepresentation.setLastName("");
        userRepresentation.setId("1");
        userRepresentation.setPrivileges(Collections.emptyList());
        userRepresentation.setGroups(Collections.emptyList());
        return userRepresentation;
    }
}